package 内置observer;import observer.DisplayElement;import java.util.Observable;import java.util.Observer;/** * Created by Administrator on 2018-10-18. */public class CurrentConditionsDisplay implements Observer, DisplayElement {    Observable observable;    private float temperature;    private float humidity;    public CurrentConditionsDisplay(Observable observable){     this.observable = observable;     observable.addObserver(this);    }    public void update(Observable o, Object arg) {       if(o instanceof  WeatherData){           WeatherData weatherData  = (WeatherData)o;           this.temperature = weatherData.getTemperature();           this.humidity = weatherData.getHumidity();           display();       }    }    public void display() {       System.out.println("当前温度:"+temperature+"湿度:" + humidity +"%");    }}